package com.ukao.steward.pesenter.valetRunners;


import com.ukao.steward.base.BasePresenter;
import com.ukao.steward.bean.AddClothingItem;
import com.ukao.steward.consts.Constant;
import com.ukao.steward.retrofit.ApiCallback;
import com.ukao.steward.view.valetRunners.AddClothingView;

import java.util.HashMap;

import rx.Observable;

/**
 * Created by ukaodev on 2017/6/26.
 */

public class AddClothingPesenter extends BasePresenter<AddClothingView> {

    public AddClothingPesenter(AddClothingView view) {
        attachView(view);
    }



    /**
     *项目       productId
     */
    public void projectData(HashMap mHashMap, final  int pos) {
      mvpView.showLoading();

        Observable observable = null;
        switch (pos){
            case 0 :  /*项目*/
                observable=apiStores.project(Constant.createParameter(mHashMap));

                break;
            case 1 :  /*衣物*/
                observable=apiStores.productInfo(Constant.createParameter(mHashMap));

                break;
            case  2: /*产品服务*/
                observable=apiStores.productService(Constant.createParameter(mHashMap));

                break;
            case  3: /*附件*/
                observable=apiStores.productAnnex(Constant.createParameter(mHashMap));

                break;
            case  4: /*颜色*/
                observable=apiStores.productColor(Constant.createParameter(mHashMap));

                break;
            case  5: /*瑕疵*/
                observable=apiStores.productFlaw(Constant.createParameter(mHashMap));
                break;
            case  6: /*洗后效果*/
                observable=apiStores.productEffect(Constant.createParameter(mHashMap));
                break;
            case  7: /*品牌*/
                observable=apiStores.productBrand(Constant.createParameter(mHashMap));
                break;
            case  8: /*附加服务*/
                observable=apiStores.productAddService(Constant.createParameter(mHashMap));
                break;
        }

        addSubscription(observable,
                new ApiCallback<AddClothingItem>() {
                    @Override
                    public void onSuccess(AddClothingItem model) {
                        if (model.getHttpCode()==200){
                            mvpView.getProjectSuccess(model.getData());
                        }else{
                            mvpView.loadFail(model.getMsg());
                        }


                    }


                    @Override
                    public void onFinish() {
                        mvpView.hideLoading();
                    }

                });



    }









}
